<template>
  <div>
    <button @click="isSho">点击显示和隐藏</button>
    <transition name="h2" appear>
      <h2 v-show="isShow">1122</h2>
    </transition>
  </div>
</template>

<script>
export default {
  name: 'TextT',
  data() {
    return {
      msg: 'text',
      isShow: true
    }
  },
  methods: {
    isSho() {
      this.isShow = !this.isShow
    }
  }
}
</script>

<style scoped>
h2 {
  width: 200px;
  height: 50px;
  background-color: tomato;
}

/* 进入起点,离开终点 */
.h2-enter,
.h2-leave-to {
  transform: translateX(-100%);
}

/* 进入动画，离开动画 */
.h2-enter-active,
.h2-leave-active {
  transition: all .5s linear;
}

/* 进入终点,离开起点*/
.h2-enter-to,
.h2-leave {
  transform: translateX(0);
}</style>